package com.b2b.controller;

import com.b2b.model.common.ResponseBean;
import com.b2b.model.entity.Notice;
import com.b2b.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/notice")
@PropertySource("classpath:config.properties")
public class NoticeController {

    @Value("${refreshTokenExpireTime}")
    private String refreshTokenExpireTime;

    private final NoticeService noticeService;

    @Autowired
    public NoticeController(NoticeService noticeService){
        this.noticeService = noticeService;
    }
    @GetMapping
    public ResponseBean get(){
        List<Notice> noticeList = new ArrayList<>();
        noticeList = noticeService.selectAll();
        return new ResponseBean(HttpStatus.OK.value(), "查询成功(Query was successful)", noticeList);
    }
}
